<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateWechatUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('wechat_users', function (Blueprint $table) {
            $table->id()->comment('微信用户表');
            $table->integer('user_id')->index()->comment('微信用户id');
            $table->smallInteger('group_id')->index()->nullable()->comment('用户所在的分组ID（兼容旧的用户分组接口）');
            $table->string('nickname',32)->comment('用户昵称');
            $table->string('avatar',255)->comment('用户头像');
            $table->string('password',64)->comment('密码');
            $table->string('phone')->comment('用户电话号');
            $table->string('qq_number')->nullable()->comment('用户绑定的qq');
            $table->tinyInteger('sex')->comment('用户的性别，值为1时是男性，值为2时是女性');
            $table->string('user_type',32)->comment('用户类型');
            $table->string('language',32)->comment('用户的语言，简体中文为zh_CN');
            $table->string('country',32)->comment('用户所在国家');
            $table->string('province',32)->comment('用户所在省份');
            $table->string('city',32)->comment('用户所在城市');
            $table->integer('second')->nullable()->comment('二级推荐人');
            $table->string('unionid',32)->nullable()->comment('只有在用户将公众号绑定到微信开放平台帐号后，才会出现该字段');
            $table->string('openid',32)->nullable()->comment('用户的标识，对当前公众号唯一');
            $table->string('remark',32)->nullable()->comment('公众号运营者对粉丝的备注，公众号运营者可在微信公众平台用户管理界面对粉丝添加备注');
            $table->string('tagid_list',32)->nullable()->comment('用户被打上的标签ID列表');
            $table->string('subscribe')->nullable()->comment('用户是否订阅该公众号标识');
            $table->timestamp('subscribe_time')->nullable()->comment('关注公众号的时间');
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('wechat_users');
    }
}
